<?php

class Adept_Template_Component_ExpressionNode extends Adept_Template_Component_Node 
{
    protected $expression;
    
    
    public function getElementRefCode() 
    {
    	return parent::getElementRefCode() . "->getChild('" 
    	   . $this->getNodeId() . "')";
    }	
        
    /**
     * @param Adept_Template_Writer_Php $writer
     */
    public function generate($writer) 
    {
        $var = $writer->generateVar();
    	$writer->writePhp("{$var} = new Adept_Component_Expression();\n");
    	
    	$writer->writePhp($this->parent->getElementRefCode());
    	$writer->writePhp("->addChild({$var});\n");
    	
    	$writer->writePhp("{$var}->setExpression(");
    	$writer->writePhpLiteral($this->getExpression());
    	$writer->writePhp(");\n");
    	$writer->writePhp("{$var}->setId(");
    	$writer->writePhpLiteral($this->getNodeId());
    	$writer->writePhp(");\n");
    }	    
    public function getExpression() 
    {
        return $this->expression;
    }
    
    public function setExpression($expression) 
    {
        $this->expression = $expression;
    }
    
}
